package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import vos.DealerSearchVo;
import vos.DealerVo;
import models.Dealer;
import models.Standard;

public interface DealerMapper {
	/**
	 * 统计列表行数
	 *
	 * @Title: countHraDetail 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countDealer(DealerSearchVo vo);
	/**
	 * 获取列表数据
	 *
	 * @Title: listHraStandard 
	 * @param vo
	 * @return
	 * @return: List<Standard>
	 */
	List<DealerVo> listDealer(DealerSearchVo vo);
	/**
	 * 批量启用经销商
	 *
	 * @Title: betchEnable 
	 * @param listid 经销商id列表
	 * @return
	 * @return: Boolean
	 */
	void betchEnable(Map<String, Object> map);
	/**
	 * 批量停用经销商
	 *
	 * @Title: betchEnable 
	 * @param listid 经销商id列表
	 * @return
	 * @return: Boolean
	 */
	void betchDisable(Map<String, Object> map);
	/**
	 * 批量删除经销商
	 *
	 * @Title: betchDel 
	 * @param map
	 * @return: void
	 */
	void betchDel(Map<String, List<String>> map);
	/**
	 * 根据id删除经销商
	 *
	 * @Title: delDealer 
	 * @param id
	 * @return: void
	 */
	@Delete("delete from "
			+ Dealer.TABLE_NAME
			+" where dealerid=#{id}")
	void delDealer(String id);
	/**
	 * 根据id判断是否存在该经销商
	 *
	 * @Title: checkCode 
	 * @param dealerid
	 * @return
	 * @return: String
	 */
	@Select("select 1 from "
			+ Dealer.TABLE_NAME
			+" where dealerid=#{dealerid}")
	String checkCode(String dealerid);
	/**
	 * 根据id获取经销商信息
	 *
	 * @Title: getById 
	 * @param dealerid 经销商id
	 * @return
	 * @return: Dealer
	 */
	@Select("select * from dealer_view"
			+" where dealerid=#{dealerid}")
	DealerVo getById(String dealerid);
	/**
	 * 保存经销商信息
	 *
	 * @Title: saveDealer 
	 * @param dealer
	 * @return: void
	 */
	@Insert("insert into "
			+ Dealer.TABLE_NAME
			+" (dealerid,dealername,resperson,resmobile,isflag,createtime,createname,remark,inviteid,email,idcard,joindate) values"
			+ "(#{dealerid},#{dealername},#{resperson},#{resmobile},#{isflag},#{createtime},"
			+ "#{createname},#{remark},#{inviteid},#{email},#{idcard},#{joindate})")
	void saveDealer(Dealer dealer);
	/**
	 * 更新经销商信息
	 *
	 * @Title: updateDealer 
	 * @param dealer
	 * @return: void
	 */
	@Update("update "
			+ Dealer.TABLE_NAME
			+" set dealername=#{dealername},"
			+ "resperson=#{resperson},resmobile=#{resmobile},isflag=#{isflag},"
			+ "modifyname=#{modifyname},modifytime=#{modifytime},"
			+ "remark=#{remark},inviteid=#{inviteid},email=#{email},"
			+ "idcard=#{idcard},joindate=#{joindate}"
			+ " where dealerid=#{dealerid}")
	void updateDealer(Dealer dealer);
	/**
	 * 获取下拉列表
	 *
	 * @Title: getCombobox 
	 * @return
	 * @return: List<Dealer>
	 */
	@Select("select dealerid,dealername from "
			+ Dealer.TABLE_NAME
			+" where isflag=false")
	List<Dealer> getCombobox();
	/**
	 * 导出为excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<DealerVo>
	 */
	List<DealerVo> exportXls(DealerSearchVo vo);
}
